package com.yang.controller;

import com.yang.pojo.SysUser;
import com.yang.service.SysUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/api/register")
public class RegisterController {

    @Resource
    SysUserService sysUserService;

    /* 注册*/
    @PostMapping("/regist")
    public Map regist(@RequestBody SysUser sysUser){
        return sysUserService.regist(sysUser);
    }

    /* 校验验证码*/
    @GetMapping("/check")
    public Map<String,Object> check(@RequestParam("username")String username, @RequestParam("code")Integer code){
        return sysUserService.checkCode(username, code);
    }

    /* 找回密码*/
    @PostMapping("/changePassword")
    public Map<String,Object> changePassword(@RequestBody Map<String,Object> map){
        String username = (String)map.get("username");
        String password = (String)map.get("password");
        return sysUserService.ChangePassword(username, password);
    }
}
